package com.ftg.learn.chapter01;

import java.util.Arrays;

/**
 * paixu排序
 *
 * @author lenovo
 * @version 1.0
 * @date 2023/5/27 11:07
 */

public class Quick1 {
    public static void main(String[] args) {
    int[] arr={10,13,2,4,5,9,11,1,6,7,19,34};
    int left=0;
    int right=arr.length-1;
    int middle=arr.length>>1;
    int x=arr[middle];
    while (true){
        while (right>left && arr[left]<x){
            left++;
        }
        while (right>left && arr[right]>x){
            right--;
        }
        if (left>=right){
            break;
        }
        arr[right]=arr[right]+arr[left];
        arr[left]=arr[right]-arr[left];
        arr[right]=arr[right]+arr[left];

    }
        System.out.println(Arrays.toString(arr));
}
 }